package fr.emse.tatiana.remotecontrol;

import fr.emse.tatiana.replayable.SynchronisationEvent;
import fr.emse.tatiana.replayable.Replayable;

public class TraceEvent {
	private long time;
	private Replayable target;
	private SynchronisationEvent se;
	 
	public TraceEvent(long time, Replayable target) {
		this.time=time;
		this.se = new SynchronisationEvent(null, time);
		this.target=target;
	}
	
	public TraceEvent(SynchronisationEvent se, Replayable target) {
		this.time= (se.getNow()==null)?-1000:se.getBegin();
		this.se=se;
		this.target=target;
	}
	
	public void trigger() {
		if (this.target == null) return;
		this.target.goTo(se);
		//System.err.println("triggered: " +this.target + " to " + time);
	}
	
	public long getTime() {
		return this.time;
	}
	
	public Replayable getTarget() {
		return this.target;
	}
	
	public void disableEvent() {
		this.target=null; // now when triggered, nothing will happen
	}
}
